import Taro from '@tarojs/taro';
import { AtNavBar } from 'taro-ui';
import { ScrollView, View } from '@tarojs/components'
import "./index.scss";

const app = Taro.getApp();

export default 
class Page extends Taro.Component {
  render() {
    const { title, leftText, className, scrollConfig = {}, isPrevPadding, onClickLeftIcon, leftIconType } = this.props;
    const { statusBarHeight, titleHeight, contentHeight, headerHeight } = app.globalData;

    return ( 
      <View className={className}>
        <View className="page-header">
          <View style={'height: ' + statusBarHeight + 'px'} />
          <View style={`height: ${titleHeight}px;background: #fff`}>
            <AtNavBar
              color='#000'
              title={title}
              leftText={leftText}
              onClickLeftIcon={onClickLeftIcon}
              leftIconType={leftIconType}
            />
          </View>
        </View>
        {
          isPrevPadding && (
            <View style={`${scrollConfig.style || ''};height: ${contentHeight - 10};top: ${headerHeight + 5}`} />
          )
        }
      </View>
    )
  }
}
